package com.simtop.pojo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import lombok.Data;
import org.apache.ibatis.type.Alias;

import java.util.Date;

/**
 * @ClassName LogInfo
 * @Description TODO   日志实体类
 * @Author lvyongwei
 * @Date 2020-08-26 9:42
 **/
@Data
@Alias("logInfo")
public class LogInfo extends BaseRowModel {

    /**
     * 日志id
     * @ExcelProperty(index = 0 , value = {"日志","日志id"})
     * 导入导出时忽略该字段
     */
    @ExcelIgnore
    private Long logId;
    /**
     *  日志描述  即具体操作内容(例如：登录)
     */
    @ExcelProperty(index = 0 , value = "日志描述")
    private String logName;
    /**
     * 用户id
     */
    @ExcelProperty(index = 1 , value = "用户id")
    private Long userId;
    /**
     * 用户名  当前操作的用户
     */
    @ExcelProperty(index = 2 , value = "用户名")
    private String userName;

    /**
     * 用户权限
     */
    @ExcelProperty(index = 3 , value = "用户权限")
    private String roleName;

    /**
     * 请求方法具体参数新信息
     */
    @ExcelProperty(index = 4 , value = "请求参数")
    private String object;
    /**
     * 成功或异常信息
     */
    @ExcelProperty(index = 5 , value = "异常信息")
    private String message;
    /**
     * 日志时间
     */
    @ExcelProperty(index = 6 , value = "日期")
    private Date logDate;

    public LogInfo() {
    }

    public LogInfo(String logName, Long userId, String userName, Integer roleId, String object, String message, Date logDate) {
        this.logName = logName;
        this.userId = userId;
        this.userName = userName;
        switch (roleId){
            case 1:
                this.roleName = "管理员";
                break;
            case 2:
                this.roleName = "教师";
                break;
            case 3:
                this.roleName = "评审专家";
                break;
            case 4:
                this.roleName = "高校学生";
                break;
            case 5:
                this.roleName = "ilab平台用户";
                break;
            default:
                this.roleName = "高校学生";
        }
        this.object = object;
        this.message = message;
        this.logDate = logDate;
    }
}
